package com.bone.business.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.bone.business.po.Business;
import com.bone.common.BaseIbatisDAO;
import com.bone.page.Page;
import com.bone.workstation.po.Module;


/**
 * DAO.
 * @author liwenzhan
 *
 */
public class BusinessDAO extends BaseIbatisDAO {
	/**
	 * 取符合条件的模块的数量.
	 * @param para
	 * @return
	 */
	public Long queryBusinessCountByParam(Map<String, Object> para){
		return (Long) getSqlMapClientTemplate().queryForObject("BUSINESS.queryByParamCount", para);
		
	}
	
	/**
	 * .
	 * @param objectId
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<Business> queryBusinessPageByParam(Map<String, Object> parameter){
		parameter.put("_order", "business_id");
		return  (List<Business>) getSqlMapClientTemplate().queryForList("BUSINESS.queryBusinessPageByParam", parameter);
	}

	/**
	 * .
	 * @param objectId
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public List<Business> queryBusinessListByParam(Map<String, Object> parameter){
		parameter.put("_order", "business_id");
		return  (List<Business>) getSqlMapClientTemplate().queryForList("BUSINESS.queryBusinessListByParam", parameter);
	} 
	/**
	 * .
	 * @param objectId
	 * @return
	 */
	public Business queryBusinessByAcount(Business business){
		Map<String, Object> para = new HashMap<String, Object>();
		para.put("businessAccount", business.getBusinessAccount());
		para.put("businessPassword", business.getBusinessPassword());
		return  (Business) super.getSqlMapClientTemplate().queryForObject("BUSINESS.queryBusinessByAcount", para);
	}
	
	
	/**
	 *  按PK取Business.
	 * @param parameter
	 * @return
	 */
	public Business queryBusinessByBusinessId(Long BusinessId){
		return  (Business) super.getSqlMapClientTemplate().queryForObject("BUSINESS.queryByBusinessId", BusinessId);
	}
	 
	/**
	 * 
	 * @param business
	 */
	public void saveOrUpdateBusiness(Business business){
	   if(business.getBusinessId()!=null && business.getBusinessId()>0){
		   getSqlMapClientTemplate().update("BUSINESS.update", business);
	   }else{
		   getSqlMapClientTemplate().insert("BUSINESS.insert", business);
	   }
	}

	 
	 
	 

}
